package com.franzliszt.maillist.util;

import android.app.Activity;

import java.util.ArrayList;
import java.util.List;
import java.util.Stack;

public class KillProcess {
    private static KillProcess killProcess = null;
    private List<Activity> activityList = new ArrayList<>(  );
    //private Stack<Activity> stack = new Stack<>();
    private KillProcess(){

    }
    public static  KillProcess getInstance(){
        if (killProcess == null){
            Sync();
        }
        return killProcess;
    }
    private static synchronized void Sync(){
        if (killProcess == null){
            killProcess = new KillProcess();
        }
    }
//    public void PoPActivity() {
//        //stack.pop();
//    }
    public void PushActivity(Activity activity){
        activityList.add(activity);
        //stack.push(activity);
    }

    public void finishAll() {
        for (Activity activity : activityList) {
            if (!activity.isFinishing()) {
                activity.finish();
            }
        }
    }
}
